import java.util.Stack;

/**
 * @author LKQ
 * @date 2022/1/7 9:46
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.maxDepth("1+(2*3)/(2-1)"));
    }

    public int maxDepth(String s) {
        Stack<Character> stack = new Stack<>();
        int depth = 0;
        for (char c: s.toCharArray()) {
            if (c == '(') {
                stack.push(c);
            }else if (c == ')') {
                depth = Math.max(depth, stack.size());
                stack.pop();
            }
        }
        return depth;
    }
}
